{php include wl_template('common/header');}
<ul class="nav nav-tabs" id="myTab">
	<li {if $_W['method'] == 'adv_list'}class="active"{/if}><a href="{php echo web_url('consumption/adv/adv_list')}">幻灯片列表</a></li>
	{if $_W['method'] == 'adv_post'}
	<li class="active"><a href="{php echo web_url('consumption/adv/adv_post')}">编辑幻灯片</a></li>
	{/if}
</ul>
{if $_W['method'] == 'adv_list'}
<div class="app-content">
	<div class="app-filter">
		<div class="filter-action">
			<a href="{php echo web_url('consumption/adv/adv_post')}" class="btn btn-primary">添加幻灯片</a>
		</div>
	</div>
	<div class="app-table-list">
		{if empty($slides)}
		<div class="no-result">
			<p>还没有相关数据</p>
		</div>
		{else}
		<form action="" class="form-table form form-validate" method="post">
			<div class="table-responsive js-table">
				<table class="table table-hover">
					<thead>
					<tr>
						<th>
							<div class="checkbox checkbox-inline">
								<input type="checkbox" name="id[]"/>
								<label></label>
							</div>
						</th>
						<th>图片</th>
						<th>排序</th>
						<th>标题</th>
						<th>状态</th>
						<th class="text-right">操作</th>
					</tr>
					</thead>
					{loop $slides $slide}
						<tr>
							<td>
								<div class="checkbox checkbox-inline">
									<input type="checkbox" name="id[]" value="{$slide['id']}"/>
									<label></label>
								</div>
							</td>
							<input type="hidden" name="ids[]" value="{$slide['id']}">
							<td><img src="{php echo tomedia($slide['thumb']);}" width="50"></td>
							<td>
								<input name="displayorders[]" value="{$slide['displayorder']}" class="form-control width-100" required="true">
							</td>
							<td>
								<input name="advnames[]" value="{$slide['advname']}" type="text" class="form-control width-100" required="true">
							</td>
							<td>
								<input name="status[]" type="checkbox" class="js-switch" {if $slide['status'] == 1}checked{/if}>
							</td>
							<td class="text-right">
								<a href="{php echo web_url('consumption/adv/adv_post', array('id' => $slide['id']))}" class="btn btn-default btn-sm" title="编辑" data-toggle="tooltip" data-placement="top" ><i class="fa fa-edit"> </i> 编辑</a>
								<a href="{php echo web_url('consumption/adv/adv_del', array('id' => $slide['id']))}" class="btn btn-default btn-sm" data-confirm="确定删除该幻灯片?" data-toggle="ajaxRemove"><i class="fa fa-times"> </i> 删除</a>
							</td>
						</tr>
					{/loop}
				</table>
				<div class="app-table-foot clearfix">
					<div class="pull-left">
						<input type="submit" class="btn btn-primary" name="submit" value="提交修改" />
						<a href="{php echo web_url('consumption/adv/adv_del')}" class="btn btn-danger" data-toggle="batch-remove" data-confirm="删除后将不可恢复，确定删除吗">批量删除</a>
					</div>
				</div>
			</div>
		</form>
		{/if}
	</div>
</div>
{/if}

{if $_W['method'] == 'adv_post'}
<div class="app-content">
	<div class="app-form">	
		<form class="form-horizontal form form-validate" id="form1" action="" method="post" enctype="multipart/form-data">
			<div class="form-group-title">编辑幻灯片</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">名称</label>
				<div class="col-sm-9">
					<input type="text" class="form-control" name="advname" value="{$slide['advname']}" required="true">
					<span class="help-block">仅用于区分,不在前台显示</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">图片</label>
				<div class="col-sm-9">
					{php echo attachment_select('thumb', $slide['thumb']);}
					<div class="help-block">建议图片尺寸:640*240</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">跳转链接</label>
				<div class="col-sm-9">
					<div class="input-group form-group" style="margin: 0;">
						<input type="text" value="{$slide['link']}" readonly="readonly" class="form-control valid" name="link" id="advlink">
						<span data-input="#advlink" data-toggle="selectUrl" class="input-group-addon btn btn-default">选择链接</span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">排序</label>
				<div class="col-sm-9">
					<input type="number" min="0" class="form-control" name="displayorder" value="{$slide['displayorder']}">
					<span class="help-block">数字越大越靠前</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">是否启用</label>
				<div class="col-sm-9">
					<div class="radio radio-inline">
						<input type="radio" name="status" value="1" id="status-1" {if $slide['status'] == 1}checked{/if}>
						<label for="status-1">启用</label>
					</div>
					<div class="radio radio-inline">
						<input type="radio" name="status" value="0" id="status-0" {if !$slide['status']}checked{/if}>
						<label for="status-0">不启用</label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-9">
					<input type="hidden" name="token" value="{$_W['token']}">
					<input type="submit" value="提交" class="btn btn-primary min-width">
				</div>
			</div>
		</form>
	</div>
</div>
{/if}
{php include wl_template('common/footer');}